package ${package.application}.api.assembler;

import ${package.application}.api.assembler.mapper.I${entity}DTOStructMapper;
import ${package.application}.api.request.${entity}CreateRequest;
import ${package.application}.api.request.${entity}QueryRequest;
import ${package.application}.api.request.${entity}UpdateRequest;
import ${package.application}.api.response.${entity}QueryResponse;
import ${package.application}.api.response.${entity}Response;
import ${package.domain}.entity.${entity};
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * ${table.comment!}类型转换器
 *
 * @author ${author}
 * @since ${date}
 */
@Component
public class ${entity}DTOAssembler {

    /**
     * ${table.comment!}创建请求数据传输对象 转 ${table.comment!}实体
     *
     * @param createRequest ${table.comment!}创建请求数据传输对象
     * @return ${table.comment!}实体
     */
    public ${entity} assembler(${entity}CreateRequest createRequest) {
        //领域模型 自行实现 entity组装工厂类 (domian层提供)
        return I${entity}DTOStructMapper.INSTANCE.fromCreateRequest(createRequest);
    }

    /**
     * ${table.comment!}更新请求数据传输对象 转 ${table.comment!}实体
     *
     * @param updateRequest ${table.comment!}更新请求数据传输对象
     * @return ${table.comment!}实体
     */
    public ${entity} assembler(${entity}UpdateRequest updateRequest) {
        //领域模型 自行实现 entity组装工厂类 (domian层提供)
        return I${entity}DTOStructMapper.INSTANCE.fromUpdateRequest(updateRequest);
    }

    /**
     * ${table.comment!}查询请求数据传输对象 转 ${table.comment!}实体
     *
     * @param queryRequest ${table.comment!}查询请求数据传输对象
     * @return ${table.comment!}实体
     */
    public ${entity} assembler(${entity}QueryRequest queryRequest) {
        //领域模型 自行实现 entity组装工厂类 (domian层提供)
        return I${entity}DTOStructMapper.INSTANCE.fromQueryRequest(queryRequest);
    }

    /**
     * ${table.comment!}实体 转 ${table.comment!}响应数据传输对象
     *
     * @param ${entity?uncap_first} ${table.comment!}实体
     * @return ${table.comment!}响应数据传输对象
     */
    public ${entity}Response toResponse(${entity} ${entity?uncap_first}) {
        return I${entity}DTOStructMapper.INSTANCE.toResponse(${entity?uncap_first});
    }

    /**
     * ${table.comment!}实体 转 ${table.comment!}查询响应数据传输对象
     *
     * @param ${entity?uncap_first} ${table.comment!}实体
     * @return ${table.comment!}查询响应数据传输对象
     */
    public ${entity}QueryResponse toQueryResponse(${entity} ${entity?uncap_first}) {
        return I${entity}DTOStructMapper.INSTANCE.toQueryResponse(${entity?uncap_first});
    }

    /**
     * ${table.comment!}实体列表 转 ${table.comment!}查询响应数据传输对象列表
     *
     * @param ${entity?uncap_first}List ${table.comment!}实体列表
     * @return ${table.comment!}查询响应数据传输对象列表
     */
    public List<${entity}QueryResponse> toQueryResponse(List<${entity}> ${entity?uncap_first}List) {
        return I${entity}DTOStructMapper.INSTANCE.toQueryResponse(${entity?uncap_first}List);
    }
}
